﻿using TallyBook.DAL.Repository.Imp;

namespace TallyBook.DAL.Repository
{
    public class RepositoryFactory<TEntity> where TEntity : class, new()
    {
        public static readonly RepositoryFactory<TEntity> Instance = new RepositoryFactory<TEntity>();

        private RepositoryFactory()
        {
        }

        public IRepository<TEntity> CreatRepository()
        {
            if (typeof (TEntity) == typeof (Account))
                return (IRepository<TEntity>) new AccountRepository();

            if (typeof (TEntity) == typeof (Outlay))
                return (IRepository<TEntity>) new OutlayRepository();

            if (typeof (TEntity) == typeof (Income))
                return (IRepository<TEntity>) new IncomeRepository();


            return (IRepository<TEntity>) new UserRepository();
        }

        public AccountRepository AccountTypeRepository()
        {
            return new AccountRepository();
        }

        public IncomeRepository IncomeTypeRepository()
        {
            return new IncomeRepository();
        }

        public OutlayRepository OutLayTypeRepository()
        {
            return new OutlayRepository();
        }
    }
}